<?php

namespace app\api\controller;

use app\api\model\User as UserModel;
use app\api\common;
/**
 * 用户管理
 * Class User
 * @package app\api
 */
class User extends Controller
{
    /**
     * 用户自动登录
     * @return array
     * @throws \app\common\exception\BaseException
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function login()
    {
        $model = new UserModel;
        $user_id = $model->login($this->request->post());
        $token = $model->getToken();
        $userData = $model->get(['user_id'=>$user_id]);
        $user_type= $userData['user_type'];
        return $this->renderSuccess(compact('user_id', 'token','user_type'));
    }
    
     /**
     *图片上传
     * @return array
     * @throws \app\common\exception\BaseException
     * @throws \think\Exception
     * @throws \think\exception\DbException
     */
    public function image()
    {
        $model = new UserModel;
        $user_id = $model->login($this->request->post());
        $token = $model->getToken();
        return $this->renderSuccess(compact('user_id', 'token'));
    }
    
 


}
